Skip to content

[codex] Structure desktop SSH prompt presentation failures - #3429

Merged
juliusmarminge merged 2 commits into
mainfrom
codex/desktop-residual-error-audit
Jun 20, 2026
Merged

[codex] Structure desktop SSH prompt presentation failures#3429
juliusmarminge merged 2 commits into
mainfrom
codex/desktop-residual-error-audit

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • record the exact Electron window operation for SSH prompt presentation failures
  • attach request correlation and window-availability stage data while preserving original causes
  • stop throwing typed errors inside Effect.try and keep failed prompt cleanup reliable

Verification

  • vp test apps/desktop/src/ssh/DesktopSshPasswordPrompts.test.ts apps/desktop/src/ssh/DesktopSshEnvironment.test.ts
  • vp check (passes with 20 existing warnings)
  • vp run typecheck

Note

Medium Risk
Touches SSH authentication UX and error mapping in the desktop app; behavior changes around edge cases (window state, renderer send failures) but is well covered by new tests.

Overview
Desktop SSH password prompts now classify failures by which Electron step failed and when the window became unavailable, instead of lumping everything into one generic window-unavailable path.

DesktopSshPromptPresentationError gains an operation label (e.g. send-prompt-request, check-window-before-request) and nullable requestId; DesktopSshPromptWindowUnavailableError adds stage (before-request, after-send, etc.) and richer messages. The request() flow is split into labeled steps via runPresentationOperation, avoids throwing typed errors inside Effect.try, and uses Effect.ensuring so pending prompts and window close listeners are always cleaned up.

If the user submits a password before a later presentation step throws, preferSubmittedPassword still returns the password instead of failing the request. New tests cover renderer send failures, pre-request window checks, cleanup after failed delivery, and the late-failure + early-resolve case.

Reviewed by Cursor Bugbot for commit 32a8c28. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Structure SSH prompt presentation failures by operation and stage in desktop

  • DesktopSshPromptPresentationError now includes a required operation field (e.g. 'check-window-before-request', 'send-prompt-request') and allows a nullable requestId for failures that occur before an ID is generated.
  • DesktopSshPromptWindowUnavailableError now carries a stage field ('before-request', 'before-presentation', 'after-send', 'after-restore') and a requestId, with a dynamic message that includes stage and destination context.
  • request() in DesktopSshPasswordPrompts.ts now performs staged window checks and wraps each presentation step in a runPresentationOperation helper that attaches the specific failing operation to any thrown error.
  • If a presentation step fails after a password has already been submitted, the implementation returns the submitted password rather than failing.
  • Behavioral Change: window unavailability and presentation errors now carry structured metadata; error messages include stage/destination context instead of a shared constant string.

Macroscope summarized 32a8c28.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 86de6c9e-ec8f-4e12-a848-b7d3f0decac8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/desktop-residual-error-audit

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jun 20, 2026
@juliusmarminge
juliusmarminge force-pushed the codex/desktop-residual-error-audit branch from 6c9ac97 to a10b0f4 Compare June 20, 2026 18:53
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

Error handling improvements for SSH prompt presentation failures with structured operation classification. The author owns this code, changes are well-tested, and the runtime behavior change (preserving already-submitted passwords) is a robustness fix rather than new feature logic.

You can customize Macroscope's approvability policy. Learn more.

Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge
juliusmarminge force-pushed the codex/desktop-residual-error-audit branch from a10b0f4 to 5ee7cfe Compare June 20, 2026 19:03
@macroscopeapp
macroscopeapp Bot dismissed their stale review June 20, 2026 19:03

Dismissing prior approval to re-evaluate 5ee7cfe

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Staged yields lose resolved password
    • Wrapped the post-send presentation operations (window destroy checks, restore, focus) in an inner Effect.gen with Effect.ignore so their failures cannot shadow an already-resolved password from the deferred, while the window-closed listener and timeout still handle genuinely-gone windows.

Create PR

Or push these changes by commenting:

@cursor push a7d1f74ac1
Preview (a7d1f74ac1)
diff --git a/apps/desktop/src/ssh/DesktopSshPasswordPrompts.ts b/apps/desktop/src/ssh/DesktopSshPasswordPrompts.ts
--- a/apps/desktop/src/ssh/DesktopSshPasswordPrompts.ts
+++ b/apps/desktop/src/ssh/DesktopSshPasswordPrompts.ts
@@ -413,34 +413,42 @@
       yield* runPresentationOperation("send-prompt-request", () =>
         window.value.webContents.send(SSH_PASSWORD_PROMPT_CHANNEL, promptRequest),
       );
-      const unavailableAfterSend = yield* runPresentationOperation("check-window-after-send", () =>
-        window.value.isDestroyed(),
-      );
-      if (unavailableAfterSend) {
-        return yield* new DesktopSshPromptWindowUnavailableError({
-          destination: input.destination,
-          requestId,
-          stage: "after-send",
-        });
-      }
-      const minimized = yield* runPresentationOperation("check-window-minimized", () =>
-        window.value.isMinimized(),
-      );
-      if (minimized) {
-        yield* runPresentationOperation("restore-window", () => window.value.restore());
-      }
-      const unavailableAfterRestore = yield* runPresentationOperation(
-        "check-window-after-restore",
-        () => window.value.isDestroyed(),
-      );
-      if (unavailableAfterRestore) {
-        return yield* new DesktopSshPromptWindowUnavailableError({
-          destination: input.destination,
-          requestId,
-          stage: "after-restore",
-        });
-      }
-      yield* runPresentationOperation("focus-window", () => window.value.focus());
+      // Once the prompt is sent the renderer can resolve the password at any
+      // scheduling boundary. The remaining steps only improve visibility
+      // (focus / restore) so their failures must not shadow an already-resolved
+      // password. Wrap them as best-effort; the window-closed listener and
+      // timeout still protect against a truly-gone window.
+      yield* Effect.gen(function* () {
+        const unavailableAfterSend = yield* runPresentationOperation(
+          "check-window-after-send",
+          () => window.value.isDestroyed(),
+        );
+        if (unavailableAfterSend) {
+          return yield* new DesktopSshPromptWindowUnavailableError({
+            destination: input.destination,
+            requestId,
+            stage: "after-send",
+          });
+        }
+        const minimized = yield* runPresentationOperation("check-window-minimized", () =>
+          window.value.isMinimized(),
+        );
+        if (minimized) {
+          yield* runPresentationOperation("restore-window", () => window.value.restore());
+        }
+        const unavailableAfterRestore = yield* runPresentationOperation(
+          "check-window-after-restore",
+          () => window.value.isDestroyed(),
+        );
+        if (unavailableAfterRestore) {
+          return yield* new DesktopSshPromptWindowUnavailableError({
+            destination: input.destination,
+            requestId,
+            stage: "after-restore",
+          });
+        }
+        yield* runPresentationOperation("focus-window", () => window.value.focus());
+      }).pipe(Effect.ignore);
       return yield* waitForPassword;
     }).pipe(Effect.ensuring(cleanup));
   });

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit 5ee7cfe. Configure here.

Comment thread apps/desktop/src/ssh/DesktopSshPasswordPrompts.ts Outdated
Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge
juliusmarminge merged commit 569b3e5 into main Jun 20, 2026
16 checks passed
@juliusmarminge
juliusmarminge deleted the codex/desktop-residual-error-audit branch June 20, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant